#ifndef ML_XML_PARSERS_H_
#define ML_XML_PARSERS_H_

#include "ZMLAlgorithm.h"
#include "tinyxml2.h"

GLOBAL_NAMESPACE_BEGIN
NAMESPACE_MACHINE_LEARNING_BEGIN

class ImageFragmentParams;
class ImageFragment;
class MLJointBoosting;
class MLDecisionStump;
class ImageLoader;

class MLXmlParsers
{
public:
    static tinyxml2::XMLElement* parseToXMLElement(tinyxml2::XMLDocument* doc, const ImageFragmentParams* params);
    static tinyxml2::XMLElement* parseToXMLElement(tinyxml2::XMLDocument* doc, const ImageFragment* params);
    static tinyxml2::XMLElement* parseToXMLElement(tinyxml2::XMLDocument* doc, const MLJointBoosting* jbAlgo);
    static tinyxml2::XMLElement* parseToXMLElement(tinyxml2::XMLDocument* doc, const MLDecisionStump* jbAlgo);
    static tinyxml2::XMLElement* parseToXMLElement(tinyxml2::XMLDocument* doc, const ImageLoader* imageLoader);

    static void* parseFromXMLElement(tinyxml2::XMLElement* elem);

    static ImageFragmentParams* parseFromXMLElement(tinyxml2::XMLElement* elem, ImageFragmentParams* param);
    static ImageFragment*       parseFromXMLElement(tinyxml2::XMLElement* elem, ImageFragment* param);
    static MLDecisionStump*     parseFromXMLElement(tinyxml2::XMLElement* elem, MLDecisionStump* param);
    static MLJointBoosting*     parseFromXMLElement(tinyxml2::XMLElement* elem, MLJointBoosting* param);
    static ImageLoader*         parseFromXMLElement(tinyxml2::XMLElement* elem, ImageLoader* imageLoader);

    enum ElementNameType {
        ML_XML_ENT_ImageFragmentParams = 0,
        ML_XML_ENT_ImageFragment,
        ML_XML_ENT_MLJointBoosting,
        ML_XML_ENT_MLDecisionStump,
        ML_XML_ENT_ImageLoader
    };

private:
    const static char* ElementNames[];
};

NAMESPACE_MACHINE_LEARNING_END
GLOBAL_NAMESPACE_END


#endif//ML_XML_PARSERS_H_